package com.liuwei.consultant.controller;

import com.liuwei.consultant.pojo.Reservation;
import com.liuwei.consultant.pojo.Result;
import com.liuwei.consultant.service.ReservationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/reservation")
@Slf4j
public class ReservationController {

    @Autowired
    private ReservationService reservationService;

    @PostMapping("/insert")
    public Result<String> insert(@RequestBody Reservation reservation) {
        log.info("插入预约信息");
        reservationService.insert(reservation);
        return Result.success("插入预约信息成功");
    }

    @GetMapping("/findByPhone")
    public Result<Reservation> findByPhone(@RequestParam String phone) {
        log.info("查询预约信息(根据手机号查询)");
        return Result.success(reservationService.findByPhone(phone));
    }
}
